package com.itheima.user;

//import com.itheima.user.config.MyRule;
//import com.netflix.loadbalancer.IRule;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
//import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients(basePackages = "com.itheima.sh.feign.order.OrderFeign")
public class UserApplication {

    public static void main(String[] args) {
        SpringApplication.run(UserApplication.class, args);
    }

    /**
     * @Description: 1.远程调用第一种方法：基于restTemPlate的远程调用
     * @return: org.springframework.web.client.RestTemplate
     * @Author: LiJianBin
     * @Date: 2021/7/6 17:12
     **/
    @Bean
    @LoadBalanced   // 开启 Ribbon 负载均衡：底层是拦截器
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }

    //只要一步 就可以修改负载均衡算法 就是下面代码
    // @Bean
    // public IRule iRule() {
    //    return new RandomRule();  // 随机算法
    //     return new MyRule();  // 自定义算法
    // }
}
